home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.20010306-20010921
/
000032_news@columbia.edu _Sat Mar 17 12:21:32 2001.msg
< prev
next >
Wrap
Internet Message Format
|
2020-01-01
|
4KB
Return-Path: <news@columbia.edu>
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
by fozimane.cc.columbia.edu (8.9.3/8.9.3) with ESMTP id MAA10750
for <kermit.misc@cpunix.cc.columbia.edu>; Sat, 17 Mar 2001 12:21:32 -0500 (EST)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.9.3/8.9.3) id MAA11425
for kermit.misc@watsun.cc.columbia.edu; Sat, 17 Mar 2001 12:07:42 -0500 (EST)
X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
From: fdc@columbia.edu (Frank da Cruz)
Subject: Re: need passive mode ftp command line client
Date: 17 Mar 2001 17:07:42 GMT
Organization: Columbia University
Message-ID: <9905ku$b4u$1@newsmaster.cc.columbia.edu>
To: kermit.misc@columbia.edu
In article <slrn9b5n4p.mt.grante@tuxtop.visi.com>,
Grant Edwards <grante@visi.com> wrote:
: On Fri, 16 Mar 2001 16:30:58 -0800, Anthony Ewell <aewell@gbis.com> wrote:
:
: > I need to write a script that will do a directory
: >of an ftp site. Then, depending on what I find in the
: >directory, do a download in passive mode. (Passive
: >mode is required to get by my firewall.)
: >
: > Does any one of a command line mode ftp client that
: >I can give a list of commands to that will also use
: >passive mode to transfer file?
:
: I believe that ncftp will do passive.
:
: Also take a look at ckermit. It supports ftp file transfer and
: has a very sophisticated scripting language akin to "expect".
:
C-Kermit 7.1 is the one that has this:
http://www.columbia.edu/kermit/ck71.html
More about its ftp client here:
http://www.columbia.edu/kermit/ftpclient.html
And a tutorial is here:
http://www.columbia.edu/kermit/ftpscript.html
And complete documentation here:
http://www.columbia.edu/kermit/ckermit3.html#ftp
About getting a directory and looking at it... There are two ways to do
this. You can use:
C-Kermit> ftp directory [ filespec ] > filename
and then read the file with FOPEN, FREAD, etc, parsing the lines, which
are in whatever format the server feels like sending them. If the server
is UNIX, the directory lines are probably like this; note that the filename
starts in column 55 (1-based):
-rw-rw---- 1 fdc staff 14169 Mar 14 11:23 foo
-rw-rw---- 1 fdc staff 28010 Mar 16 12:05 h
-rw-r--r-- 1 fdc staff 19294 Mar 16 12:06 j.jpg
-rw-rw---- 1 fdc staff 46949 Mar 16 15:35 kt
-rw-rw---- 1 fdc staff 489 Mar 13 10:37 r
-rw-rw---- 1 fdc staff 3374 Mar 13 10:36 r.~1~
Let's say you've stored the directory listing in a file called dirlist
fopen \%c dirlist ; Open dirlist and assign channel number to \%c
if fail exit 1 Can't open directory list file
.\%n = 0
while true {
fread \%c line ; Read a line into variable named 'line'
if fail break ; EOF
.fn := \s(line[55]) ; Extract substring from col 55 to end
echo [\m(fn)] ; Echo the filename with brackets around it
increment \%n ; Count it
}
fclose \%c ; Done - close file
echo Files: \%n ; Tell how many filenames
Once you have isolated the filename (fn) you can do whatever you want
with it -- compare it with a pattern, a list, etc. Then to download in
passive mode, simply:
set ftp passive
get \m(fn)
if fail exit 1 GET \m(fn) failed.
C-Kermit 7.1 is currently in prerelease testing, so this is a good time
to try it and send in any comments or suggestions about the scriptable
FTP client. In fact, your problem suggests one improvement already, which
is to make the NLST result available to the program directly, so you don't
have to parse arbitrary directory-listing formats.
- Frank